package com.da.javatest.leetCode2;

public class Code240 {
    public boolean searchMatrix(int[][] matrix, int target) {
        int length = matrix.length;
        int y = length == 0 ? -1 : matrix[0].length - 1;
        if (y < 0) {
            return false;
        }
        for (int[] row : matrix) {
            for (; y >= 0; --y) {
                int cur = row[y];
                if (cur == target) {
                    return true;
                } else if (cur > target) {
                } else {
                    break;
                }
            }
        }
        return false;
    }
}
